<%@ page pageEncoding="UTF-8"%>
<div id="toploginbar">
<c:if test="${HostUser==null}">
<div id="logininstatus">
	<label for="userName">用户名：</label><input type="text" name="userName" id="userName" class="qtextbox">
	<label for="passWord">密码：</label><input type="password" name="passWord" id="passWord" class="qtextbox">
	<input type="button" class="qbutton" id="login" value="登陆">
<a href="${HomeUrl}/user">注册</a>
</div>
<div id="loginoutstatus" style="display:none">

<span id="topuserinfo">&nbsp;&nbsp;普通会员&nbsp;&nbsp;欢迎你：<span id="userNameInfo" >游客!</span></span>

<a href="${HomeUrl}/qmanager">［进入管理中心］</a>
<a href="javascript:" id="loginout">退出登录</a>
</div>
</c:if>
<c:if test="${HostUser!=null}">
<div id="logininstatus" style="display:none">
	<label for="userName">用户名：</label><input type="text" name="userName" id="userName" class="qtextbox">
	<label for="passWord">密码：</label><input type="password" name="passWord" id="passWord" class="qtextbox">
	<input type="button" class="qbutton" id="login" value="登陆">
<a href="${HomeUrl}/user">注册</a>
</div>
<div id="loginoutstatus" >

<span id="topuserinfo">&nbsp;&nbsp;普通会员&nbsp;&nbsp;欢迎你：<span id="userNameInfo" >${HostUser.userName }!</span></span>

<a href="${HomeUrl}/qmanager">［进入管理中心］</a>
<a href="javascript:" id="loginout">退出登录</a>
</div>
</c:if>
<script type="text/javascript" src="${HomeUrl}/views/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
  $(function(){
  $("#login").click(function()
  {
     var username=$("#userName").val();
     var password=$("#passWord").val();
     $.post("${HomeUrl}/login/loginIn",{userName:username,passWord:password},function(r)
     {
        if(r.code==1)    
        {
           
           $("#userNameInfo").html(username);
           $("#logininstatus").hide();
           $("#loginoutstatus").show();
        }
        else
        alert("帐号或密码错误！！！");
     },"json");
  }); 
  $("#loginout").click(function()
  {
    $.post("${HomeUrl}/login/loginOut",{},function(r)
    {
      if(r.code==1)
      {
           $("#userNameInfo").html("游客");
           $("#logininstatus").show();
           $("#loginoutstatus").hide();
      }
      else
      alert("退出失败");
    },"json");
  }); 
});  
</script>
</div>